package com.atsansan.mywork.login.controller;

import com.atsansan.mywork.login.entity.CourseraEntity;
import com.atsansan.mywork.login.pachong.CourseraInfo;
import com.atsansan.mywork.login.service.CourseraService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author sansan
 * @create 2021-04-09 22:09
 */
@Controller
@RequestMapping("coursera")
public class CourseraPaChongController {


    @RequestMapping("/pa")
    public String pa(@RequestParam("cname") String url, Map<String,Object> map)  {

        List<CourseraEntity> courseras = null;
        try {
            courseras = CourseraInfo.getCoursera(url);
        } catch (IOException e) {
            e.printStackTrace();
            return "redirect:/error2";
        }


        System.out.println(courseras.get(0).getCLevel());
        System.out.println(courseras.toString());
        map.put("courseras",courseras);
        return "select";

    }
}
